#!/bin/env python

import time
import cv2
import numpy as np

pic_path = "../resource/pic/img_003.jpg"
pic_path2 = "../resource/pic/img_004.jpg"
# windowName = pic_path

# cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
# cv2.resizeWindow(windowName, 1500, 500)
pic1 = cv2.imread(pic_path)
pic2 = cv2.imread(pic_path2)

print("pic1 shape:", pic1.shape)
print("pic1 size:", pic1.size)
print("pic1 dtype:", pic1.dtype)

print("pic2 shape:", pic2.shape)
print("pic2 size:", pic2.size)
print("pic2 dtype:", pic2.dtype)


cv2.imshow("pic1", pic1)
# cv2.imshow("pic2", pic2)

new_pic1 = cv2.resize(pic1, (200, 200), interpolation=cv2.INTER_NEAREST)  # 临近插值，速度快，效果差
cv2.imshow("INTER_NEAREST", new_pic1)
new_pic1 = cv2.resize(pic1, (200, 200), interpolation=cv2.INTER_LINEAR)   # 双线性插值，使用4个点插值，默认
cv2.imshow("INTER_LINEAR", new_pic1)
new_pic1 = cv2.resize(pic1, (200, 200), interpolation=cv2.INTER_CUBIC)    # 三次插值，使用16个点插值
cv2.imshow("INTER_CUBIC", new_pic1)
new_pic1 = cv2.resize(pic1, (200, 200), interpolation=cv2.INTER_AREA)     # 区域插值，速度慢，效果好
cv2.imshow("INTER_AREA", new_pic1)

new_pic1 = cv2.resize(pic1, dsize=None, fx = 1.5, fy = 0.5, interpolation=cv2.INTER_AREA)     # 比例拉伸
cv2.imshow("porportion", new_pic1)

new_pic2 = cv2.resize(pic2, (200, 200))

# img = cv2.addWeighted(new_pic1, 0.5, new_pic2, 0.5, 0)
# cv2.imshow("addWeighted", np.hstack((new_pic1, new_pic2, img)))

while True:
    if cv2.waitKey(0) == ord('q'):
        break

print('销毁窗口')
cv2.destroyAllWindows()
